//
//  XKTradeRecordView.m
//  XKJY
//
//  Created by xuyaguang on 2017/1/14.
//  Copyright © 2017年 xiaokang100. All rights reserved.
//

#import "XKTradeRecordView.h"

@interface XKTradeRecordView ()

@property (nonatomic, strong) UILabel  *lineTop;
@property (nonatomic, strong) UILabel  *lineLeft;
@property (nonatomic, strong) UILabel  *titleLabel;
@property (nonatomic, strong) UIButton *moreBtn;

@property (nonatomic, strong) UIView  *grayView;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *typeLabel;
@property (nonatomic, strong) UILabel *priceLabel;
@property (nonatomic, strong) UILabel *numLabel;
@property (nonatomic, strong) UILabel *totalLael;

@end
@implementation XKTradeRecordView

#pragma mark - 重写构造方法
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
        [self initSubviews];
        
    }
    return self;
}

#pragma mark - 设置自身
- (void)setupUI {
    self.backgroundColor = WhiteColor;
}

#pragma mark - 创建控件
- (void)initSubviews {
    
    _lineTop = [UILabel new];
    _lineTop.backgroundColor = kBaseGrayColor;
    
    _lineLeft = [UILabel new];
    _lineLeft.backgroundColor = RedColor;
    
    _titleLabel = [UILabel getLabWithText:@"我的成交" textFont:Font_15 textColor:BlackColor];
    
    _moreBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    _moreBtn.titleLabel.font = Font(13);
    _moreBtn.titleLabel.textAlignment = NSTextAlignmentRight;
    [_moreBtn setTitle:@"更多" forState:UIControlStateNormal];
    
    
    _grayView = [UIView new];
    _grayView.backgroundColor = kBaseGrayColor;
    
    _timeLabel = [UILabel getLabWithText:@"成交时间" textFont:Font_13 textColor:BlackColor textAlignment:NSTextAlignmentLeft];
    
    _typeLabel = [UILabel getLabWithText:@"类型" textFont:Font_13 textColor:BlackColor textAlignment:NSTextAlignmentCenter];
    
    _priceLabel = [UILabel getLabWithText:@"成交价格" textFont:Font_13 textColor:BlackColor textAlignment:NSTextAlignmentCenter];
    
    _numLabel = [UILabel getLabWithText:@"成交量" textFont:Font_13 textColor:BlackColor textAlignment:NSTextAlignmentCenter];
    
    _totalLael = [UILabel getLabWithText:@"成交金额" textFont:Font_13 textColor:BlackColor textAlignment:NSTextAlignmentRight];
    
    [self addSubview:self.lineTop];
    [self addSubview:self.lineLeft];
    [self addSubview:self.titleLabel];
    [self addSubview:self.moreBtn];
    [self addSubview:self.grayView];
    
    [self.grayView addSubview:self.timeLabel];
    [self.grayView addSubview:self.typeLabel];
    [self.grayView addSubview:self.priceLabel];
    [self.grayView addSubview:self.numLabel];
    [self.grayView addSubview:self.totalLael];
    
    
    
    [self addConstraints];
}
#pragma mark - 添加约束
- (void)addConstraints {
    
    
    [self.lineTop mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(self);
        make.height.mas_equalTo(5*Scale_H);
    }];
    
    [self.lineLeft mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).offset(10*Scale_W);
        make.top.mas_equalTo(self.lineTop.mas_bottom).offset(5*Scale_W);
        make.width.mas_equalTo(3*Scale_H);
        make.height.mas_equalTo(20*Scale_H);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.lineLeft.mas_right).offset(10*Scale_W);
        make.centerY.mas_equalTo(self.lineLeft);
    }];
    
//    [self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.mas_equalTo(self).offset(-10*Scale_W);
//        make.centerY.mas_equalTo(self.lineLeft);
//    }];
    
    [self.grayView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self);
        make.top.mas_equalTo(self.lineLeft.mas_bottom).offset(5*Scale_H);
        make.height.mas_equalTo(30*Scale_H);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.grayView).offset(22*Scale_W);
        make.centerY.mas_equalTo(self.grayView);
        make.width.mas_equalTo(Main_Width/6);
    }];
    
    [self.typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.timeLabel);
        make.left.mas_equalTo(self.timeLabel.mas_right).offset(10*Scale_W);
        make.width.mas_equalTo(Main_Width/6*0.7);
    }];
    
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.timeLabel);
        make.left.mas_equalTo(self.typeLabel.mas_right).offset(10*Scale_W);
        make.width.mas_equalTo(Main_Width/7);
    }];
    
    [self.numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.timeLabel);
        make.left.mas_equalTo(self.priceLabel.mas_right).offset(10*Scale_W);
        make.width.mas_equalTo(Main_Width/5);
    }];
    
    [self.totalLael mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.timeLabel);
        make.right.mas_equalTo(self.grayView).offset(-10*Scale_W);
        make.left.mas_equalTo(self.numLabel.mas_right).offset(10*Scale_W);
    }];

}


@end
